/*

http://codekata.pragprog.com/2007/01/kata_two_karate.html

Alberto Massa
11th of April, 2010

*/


#include <assert.h>

void test() {
	assert(-1 == chop( 3, (int[]){}, 0 ));
	assert(-1 == chop( 3, (int[]){1}, 1 ));
	assert(0 ==  chop( 1, (int[]){1}, 1 ));

	assert(0 ==  chop(1, (int[]){1, 3, 5}, 3));
	assert(1 ==  chop(3, (int[]){1, 3, 5}, 3));
	assert(2 ==  chop(5, (int[]){1, 3, 5}, 3));
	assert(-1 == chop(0, (int[]){1, 3, 5}, 3));
	assert(-1 == chop(2, (int[]){1, 3, 5}, 3));
	assert(-1 == chop(4, (int[]){1, 3, 5}, 3));
	assert(-1 == chop(6, (int[]){1, 3, 5}, 3));

	assert(0 ==  chop(1, (int[]){1, 3, 5, 7}, 4));
	assert(1 ==  chop(3, (int[]){1, 3, 5, 7}, 4));
	assert(2 ==  chop(5, (int[]){1, 3, 5, 7}, 4));
	assert(3 ==  chop(7, (int[]){1, 3, 5, 7}, 4));
	assert(-1 == chop(0, (int[]){1, 3, 5, 7}, 4));
	assert(-1 == chop(2, (int[]){1, 3, 5, 7}, 4));
	assert(-1 == chop(4, (int[]){1, 3, 5, 7}, 4));
	assert(-1 == chop(6, (int[]){1, 3, 5, 7}, 4));
	assert(-1 == chop(8, (int[]){1, 3, 5, 7}, 4));
}
